﻿@{
    Layout = null;

    string code = ViewBag.Code;
}

<!DOCTYPE html>

<html>
<head>
    <title>爱炒股联合登录</title>
    <script src="http://static.emoney.cn/js/libs/jquery.min.1.8.3.js" type="text/javascript"></script>
</head>
<body>
    @*<div>内网测试</div>
    <div>Code:@code</div>
    <div><a href="@(Url.Content("~/oauth/qqshow?code="+code+""))">查看QQ信息</a></div>*@
    <div id="divMsg"></div>
    <input type="hidden" id="hidCode" value="@code" />
    <input type="hidden" id="hidNick" value="@ViewBag.Nickname" />
    <input type="hidden" id="hidReturnUrl" value="@ViewBag.ReturnUrl" />
    <input type="hidden" id="hidBindUserID" value="@ViewBag.BindUserID" />
</body>
</html>
<script type="text/javascript">
    var verifierCode = $("#hidCode").val(), err = "", msg = "", url = $("#hidReturnUrl").val(), nick = $("#hidNick").val(), binduserid = $("#hidBindUserID").val();

    if (url != "") {
        window.location.href = "http://dsclient.emoney.cn/qqlogin.html?nick=" + escape(nick);
    }
    else {
        if (verifierCode != "" && binduserid != "") {
            window.location.href = "http://dsclient.emoney.cn/istockclient/oauth/qq?code=" + verifierCode + "&returnUrl=bind|" + binduserid;
            //$.ajax({
            //    type: "post",
            //    url: "http://192.168.8.102/istockoauth/oauth/bindqq",
            //    data: {code:verifierCode,userid:binduserid},
            //    datatype: "text",
            //    success: function (data) {
            //        $("#divMsg").html(data);
            //    },
            //    beforeSend: function () {
            //        $("#divMsg").html("绑定中，请稍后...");
            //    },
            //    error: function (XMLHttpRequest, textStatus, errorThrown) {
            //        //alert(XMLHttpRequest.status);
            //    }
            //});
        }
        else {
            if (verifierCode == "") {
                err = "-1";
                msg = "获取临时授权code失败！";
            }
            else {
                err = "0";
                msg = "";
            }

            var data = "{\"err\": " + err + ",\"msg\": \"" + msg + "\",\"from\": " + 100 + ",\"code\": \"" + verifierCode + "\"}";

            try {
                window.external.OnCallLocalFunction("OnOAuthLogin", data);
            } catch (ex) {
            }
        }
    }
</script>